<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "https://raw.githubusercontent.com/rbatis/rbatis/master/rbatis-codegen/mybatis-3-mapper.dtd">
<mapper>
    <sql id="a">` and id != '' `</sql>
    <insert id="insert">
        `insert into activity`
        <foreach collection="arg" index="key" item="item" open="(" close=")" separator=",">
            <if test="key == 'id'">
                <continue/>
            </if>
            ${key}
        </foreach>
        ` values `
        <foreach collection="arg" index="key" item="item" open="(" close=")" separator=",">
            <if test="key == 'id'">
                <continue/>
            </if>
            ${item}
        </foreach>
    </insert>
    <select id="select_by_condition">
        `select * from activity`
        <where>
            <include refid="a"></include>
            <include refid="file://./example/example.html?refid=a"></include>
            <if test="name != ''">
                ` and name like #{name}`
            </if>
            <if test="dt >= '2009-12-12 00:00:00'">
                ` and create_time < #{dt}`
            </if>
            <choose>
                <when test="true">
                    ` and id != '-1'`
                </when>
                <otherwise>and id != -2</otherwise>
            </choose>
            ` and `
            <trim prefixOverrides=" and">
                ` and name != '' `
            </trim>
        </where>
    </select>

    <select id="select_page_data">
        `select `
        <if test="do_count == true">
            `count(1)`
        </if>
        <if test="do_count == false">
            `*`
        </if>
        ` from activity`
        <where>
            <if test="name != ''">
                ` and name like #{name}`
            </if>
            <if test="dt >= '2009-12-12 00:00:00'">
                ` and create_time < #{dt}`
            </if>
            <choose>
                <when test="true">
                    ` and id != '-1'`
                </when>
                <otherwise>and id != -2</otherwise>
            </choose>
            ` and `
            <trim prefixOverrides=" and">
                ` and name != '' `
            </trim>
            <if test="do_count == false">
                ` limit ${page_no},${page_size}`
            </if>
        </where>
    </select>
</mapper>